
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>B+树和B-树有哪些区别？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>B+树和B-树有哪些区别？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">B-树是一种什么样的数据结构？其节点通常包含哪些内容？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">B-树（Balanced Tree）是一种自平衡的多叉树。它的每个节点都存储了键和值对（数据），以及指向子树的指针。在B-树中，所有节点的高度相同，这保证了高效的查找性能。</div>
          </div>
          <div class="card-source">来源: B-树的基本概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">B+树与B-树在节点存储内容上的根本区别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">B-树的所有节点（包括非叶子节点和叶子节点）都存储键和值对。而B+树的非叶子节点只存储键值和指向子节点的指针，不存储实际数据，所有的数据都存储在叶子节点中。</div>
          </div>
          <div class="card-source">来源: B+树和B-树的主要区别 - 节点内容差异</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">为什么B+树在执行范围查询和顺序访问时性能通常优于B-树？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为B+树的所有叶子节点通过一个双向链表连接。当执行范围查询时，只需定位到范围的起始点，然后沿链表顺序遍历即可，无需回溯树的结构。而B-树的叶子节点之间没有链接。</div>
          </div>
          <div class="card-source">来源: B+树和B-树的主要区别 - 查询性能差异</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">B+树的非叶子节点设计如何帮助其降低磁盘I/O次数？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">由于B+树的非叶子节点只存储键值和指针，不存储实际数据，所以节点本身更加紧凑，可以在一个节点内存储更多的键。这使得树的阶数更高，整体高度更低，从而减少了从根节点到叶子节点查询时所需的磁盘I/O次数。</div>
          </div>
          <div class="card-source">来源: B+树和B-树的主要区别 - 树的高度和磁盘I/O</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">B+树最典型的应用场景是什么？为什么它适合这些场景？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">B+树通常用于数据库和文件系统等大规模存储应用中。因为它在磁盘I/O效率和范围查询方面具有优势，其结构允许系统快速地找到数据并进行顺序读取，这对于磁盘存储系统至关重要。</div>
          </div>
          <div class="card-source">来源: 应用场景的选择</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在什么情况下，选择B-树可能比B+树更合适？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">B-树更适合需要频繁进行插入、删除操作且数据量相对较小的应用场景，因为它的插入和删除操作可以更直接地进行，而无需大量的节点拆分和合并。</div>
          </div>
          <div class="card-source">来源: 应用场景的选择</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
